import { _decorator, Component, Node, utils } from 'cc';
import { BehaviorTree } from '../BehaviorTree';
import { DelayNode } from '../BNode/DelayNode';
import { SequenceTree } from '../BTree/SequenceTree';
import { ActionNode } from '../BNode/ActionNode';
import { SelectTree } from '../BTree/SelectTree';
import { ParallelTree } from '../BTree/ParallelTree';
import { BTree } from '../utils/BTree';
const { ccclass, property } = _decorator;

const b = BTree;

@ccclass('Example_2')
export class Example_2 extends Component {
    behaviorTree = new BehaviorTree();
    start() {
        this.test1();
    }

    //测试 条件 checkout
    test1() {
        const data = { x: 10, y: 'hello' };

        this.behaviorTree.blackBoard = data;
        const tree = BTree.check(
            false,
            b.call(() => {
                console.log('A');
            }),
            b.call(() => {
                console.log('B');
            }),
        );
        this.behaviorTree.root.addChild(tree);
        this.behaviorTree.run();
    }

    update(deltaTime: number) {
        this.behaviorTree.update(deltaTime);
    }
}
